# 导入库
from py_commander import Network
import time

target_ip = "192.168.189.1"

# 启动服务器
server_thread = Network.start_server(port=9999)
print("服务器已启动，开始监听消息...")


time.sleep(3)
# 发送消息
print("发送测试消息：开始")
Network.send_message(target_ip, "开始", port=9999)

time.sleep(3)
print("发送测试消息：暂停")
Network.send_message(target_ip, "暂停", port=9999)

time.sleep(3)
print("发送测试消息：停止")
Network.send_message(target_ip, "停止", port=9999)

while True:
    # 持续监听，接收信息
    msg = Network.get_message()
    time.sleep(0.5)
    if msg != None:
        print("收到消息：" + msg['message'])





